﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsTest
{
   public class DbHelper
    {
    private static  readonly string constring = "server=.;database=Admin3000;uid =sa;pwd=cyq1111;";
       public static DataTable GetDataTable(string sql)
       {
           
          
           SqlConnection connection = new SqlConnection(constring);
           connection.open();
           sqldataadapter adapter = new sqldataadapter(sql, connection);
           
           connection.open();

           DataTable dt = new DataTable();

           adapter.Fill(dt);

           return dt;

       }
       public static int AddOrUpdate(string sql)
       {
           SqlConnection connection = new SqlConnection(constring);
           sqlCommand command = new sqlCommand(sql,connection);
           int i = command.ExecuteNonQuery();
           connection.open();
           return i;
       }
    }

}
